package com.sysmanage.etl.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "ETL_RULE")
public class ETL_Rule implements Serializable {
	private static final long serialVersionUID = -2358308181790202690L;
	public static final Integer RULE_TYPE_QUERY = 0;
	public static final Integer TULE_TYPE_ADD = 1;
	public static final Integer RULE_TYPE_UPDATE = 2;
	public static final Integer TULE_TYPE_DELETE = 3;

	private Integer rule_id;
	/** 操作类型 0-查询；1-新增；2：修改；3删除 */
	private Integer rule_type;
	/** 操作顺序 */
	private Integer rule_index;
	/** 所属门店 */
	private Integer shop_id;
	/** 查询返回值 */
	private ETL_Property rule_return_property;
	/** 字段和Excel列对应关系 */
	private Set<ETL_Property_Column> propertyColumns;
	/** 数据表 */
	private ETL_Table table;

	@Id
	@GeneratedValue
	@Column(name = "RULE_ID")
	public Integer getRule_id() {
		return rule_id;
	}

	public void setRule_id(Integer rule_id) {
		this.rule_id = rule_id;
	}

	@Column(name = "RULE_TYPE")
	public Integer getRule_type() {
		return rule_type;
	}

	public void setRule_type(Integer rule_type) {
		this.rule_type = rule_type;
	}

	@Column(name = "RULE_INDEX")
	public Integer getRule_index() {
		return rule_index;
	}

	public void setRule_index(Integer rule_index) {
		this.rule_index = rule_index;
	}

	@Column(name = "SHOP_ID")
	public Integer getShop_id() {
		return shop_id;
	}

	public void setShop_id(Integer shop_id) {
		this.shop_id = shop_id;
	}

	@OneToMany(mappedBy = "rule", fetch = FetchType.EAGER)
	public Set<ETL_Property_Column> getPropertyColumns() {
		return propertyColumns;
	}

	public void setPropertyColumns(Set<ETL_Property_Column> propertyColumns) {
		this.propertyColumns = propertyColumns;
	}

	@ManyToOne
	@JoinColumn(name = "TABLE_ID")
	public ETL_Table getTable() {
		return table;
	}

	public void setTable(ETL_Table table) {
		this.table = table;
	}

	@ManyToOne
	@JoinColumn(name = "RETURN_PROPERTY_ID")
	public ETL_Property getRule_return_property() {
		return rule_return_property;
	}

	public void setRule_return_property(ETL_Property rule_return_property) {
		this.rule_return_property = rule_return_property;
	}

}
